package com.lagou.lagouserviceuser.controller;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;

import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.sql.DataSource;
import java.sql.SQLException;

/**
 * @Authther: mrwu
 * @date:2021/4/23-04
 * @Description:com.lagou.lagouserviceuser.controller
 */
@RestController
public class TestController implements BeanPostProcessor {

    private ConfigurableApplicationContext context;
    @Autowired
    DataSource dataSource;
    @Autowired
    DataSourceProperties dataSourceProperties;

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        System.out.println(beanName+"=====beanname");
        return bean;
    }

    @GetMapping("/user/view")
    public void viewconfig(){

        try {
            dataSource.getConnection();
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        System.out.println(dataSourceProperties);
    }


}
